﻿using Anni.Weixin.API.weixin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Anni.Weixin.WebForm.SDK {
	public partial class share : System.Web.UI.Page {
		//配置
		protected string appId = "wx55152097311458ff";           //应用ID/开发者IDwzlx521an040925f08
		protected const string appSecret = "0a72064a57c71aaab8c66ad32e625dd8"; //应用密钥50ac3644fzlx2391092591521a0dd076
		protected string timestamp = string.Empty;       //必填，生成签名的时间戳
		protected string nonceStr = string.Empty;		// 必填，生成签名的随机串
		protected string signature = string.Empty;      // 必填，签名
		//自定义分享
		protected string title = "安妮鲜花淘宝授权店折上折";
		protected string desc = "安妮鲜花淘宝授权店折上折，9折电子优惠券";
		protected string link = "http://abc.com";
		protected string imgUrl = "http://abc.com/John.gif";
		protected void Page_Load(object sender, EventArgs e) {
			if (!IsPostBack) {
				CreateConfig();
			}
		}
		/// <summary>
		/// 配置config必填信息
		/// </summary>
		private void CreateConfig() {
			WeiXinJSSDK jssdk = new WeiXinJSSDK();
			timestamp = jssdk.GenerateTimeStamp();
			nonceStr = jssdk.GenerateNonceStr();
			string url = Request.Url.ToString().Replace("#", "");  //签名用的url必须是调用JS接口页面的完整URL。
			signature = new WeiXinJSSDK(appId, appSecret).GenerateSignature(Convert.ToInt64(timestamp), nonceStr, url);
		}
	}
}